<? $section='Users'; ?>
<?php include('../../inc/header.php'); ?>
<?php include('../../inc/menu.php'); ?>
<?php include('../../inc/ads.php'); ?>
<?php //include content.php for viewing here
?>

<?
        require_once '../../inc/functions.php';
        require_once 'data.php';
        //print_r($_REQUEST);
        if(isset($_REQUEST['Save']))
        {
                $rs = $_REQUEST;
                $errors = Users::Validate($rs);
                if(!$errors)
                        $errors = Users::Save($rs);
                if(!$errors)
                {
                        header("Location: index.php?new_id=$rs[id]");
                }
        }
        elseif(isset($_REQUEST['id']))
                $rs = Users::Get($_REQUEST['id']);
        else
                $rs = Users::Blank();
?>





<!-- start content (written section, not content.php) -->

<div id="content">
<div class="post">
<h3>Users-Edit</h3>

<h1>Add a User</h1>
        <ul class="error">
                <? foreach($errors as $field => $error){ ?>
                <li><?=$field?>: <?=$error?></li>
            <? } ?>
        </ul>
        
        <form method="post" action="">
        
<table width="70%" >

  <tr>
        <td><label>id:</label> <!-- this is autogen --></td>
    	<td><?=$rs['id']?></td>
  </tr>
  <tr>
    <td><label for="FirstName">First Name</label></td>
    <td><input type="text"
               name="FirstName" id="FirstName"
               value="<?=$rs['FirstName']?>"
               class="<?=isset($errors['FirstName']) ? 'error' : '' ?>" />
               <span class="error"><?=$errors['FirstName']?></span></td>
  </tr>
    <tr>
    <td><label for="LastName">Last Name</label></td>
    <td><input  type="text"
                name="LastName" id="LastName"
                alue="<?=$rs['LastName']?>"
                class="<?=isset($errors['LastName']) ? 'error' : '' ?>" />
            <span class="error"><?=$errors['LastName']?></span></td>
  </tr>
    <tr>
    <td><label for="Address">Address</label></td>
    <td><input type="text"
               name="Address" id="Address"
               value="<?=$rs['Address']?>"
               class="<?=isset($errors['Address']) ? 'error' : '' ?>" />
            <span class="error"><?=$errors['Address']?></span></td>
  </tr>
    <tr>
    <td><label for="City">City</label></td>
    <td>                    <input  type="text"
                            name="State" id="State"
                        value="<?=$rs['State']?>"
                        class="<?=isset($errors['State']) ? 'error' : '' ?>" />
            <span class="error"><?=$errors['State']?></span></td>
  </tr>
    <tr>
    <td><label for="State">State</label></td>
    <td>                    <input  type="text"
                            name="City" id="City"
                        value="<?=$rs['City']?>"
                        class="<?=isset($errors['City']) ? 'error' : '' ?>" />
            <span class="error"><?=$errors['City']?></span></td>
  </tr>
    <tr>
    <td><label for="Zipcode">Zipcode</label></td>
    <td>                    <input  type="text"
                            name="Zipcode" id="Zipcode"
                        value="<?=$rs['Zipcode']?>"
                        class="<?=isset($errors['Zipcode']) ? 'error' : '' ?>" />
            <span class="error"><?=$errors['Zipcode']?></span></td>
  </tr>
    <tr>
    <td><label for="Handle">Handle</label></td>
    <td>                    <input  type="text"
                            name="Handle" id="Handle"
                        value="<?=$rs['Handle']?>"
                        class="<?=isset($errors['Handle']) ? 'error' : '' ?>" />
            <span class="error"><?=$errors['Handle']?></span></td>
  </tr>
    <tr>
    <td><label for="Password">Password</label></td>
    <td>                <input  type="text"
                        name="Password" id="Password"
                    value="<?=$rs['Password']?>"
                    class="<?=isset($errors['Password']) ? 'error' : '' ?>" />
            <span class="error"><?=$errors['Password']?></span></td>
  </tr>
    <tr>
    <td><label for="FacebookID">FacebookID</label></td>
    <td>                <input  type="number"
                        name="FacebookID" id="FacebookID"
                    value="<?=$rs['FacebookID']?>"
                    class="<?=isset($errors['FacebookID']) ? 'error' : '' ?>" />
            <span class="error"><?=$errors['FacebookID']?></span></td>
  </tr>
  <tr>
    <td><label for="PictureURL">PictureURL</label></td>
    <td>                <input  type="text"
                        name="PictureURL" id="PictureURL"
                    value="<?=$rs['PictureURL']?>"
                    class="<?=isset($errors['PictureURL']) ? 'error' : '' ?>" />
            <span class="error"><?=$errors['PictureURL']?></span></td>
  </tr>
</table>

            <input type="submit" value="Save"  name="Save"/>
        </form>
        
        <?
                        $_REQUEST['UserID'] = $rs['id'];
                       // include '../Users/index.php';
                ?>





</div>
</div> <!-- end content -->
<?php include('../../inc/sidebar.php'); ?>
<?php include('../../inc/footer.php'); ?>
